<!DOCTYPE html>
<html lang="zh-cn">
<head>
{include file="public/header" /}
</head>
<body>
<div class="panel admin-panel">
<div class="panel-head"><strong class="icon-menu"> 内容管理</strong></div>
<div class="padding border-bottom">
  <ul class="search" style="padding-left:10px;">
    <li><button type="button"  class="button border-green" id="checkall"><span class="icon-xuanze"></span> 全选</button></li>
    <li><button type="submit" class="button border-red" onclick="delall()" id="checkdel"><span class="icon-shanchu"></span> 批量删除</button></li>
    
  	<form action="{:url('content/lst')}" method="POST">
	  	<li>
		  	<select name="cid" class="input w50" id="options" style="width: 100%;">
		        <option value="0">请选择分类</option>
		    </select>
	    </li>
	    <li>
	  	<input type="text" placeholder="请输入搜索关键字" name="keywords" class="input" />
	  	</li>
	  	<li><button type="submit" class="button border-main" id="checkdel"><span class="icon-sousuo"></span> 搜索</button></li>
  	</form>
  </ul>
</div>
<form method="post" action="" id="listform">
    <table class="table table-hover text-center">
      <tr>
        <th width="100" style="text-align:left; padding-left:20px;">ID</th>
        <th>图片</th>
        <th>图片名称</th>
        <th>分类名称</th>
        <th width="10%">添加时间</th>
        <th width="310">操作</th>
      </tr>
      {volist name="annxpic" id="vo"}
        <tr>
          <td style="text-align:left; padding-left:20px;"><input type="checkbox" name="id[]" value="{$vo.id}" title="{$vo.picsrc}" />{$vo.id}</td>
          <td class="tbimg" width="10%"><div><img src="{$vo.picsrc}" alt="" /></div></td>
          <td>{$vo.picname}</td>
          <td>{$vo['prname']|catname}</td>
          <td>{$vo['sctime']|date='Y-m-d',###}</td>
          <td><div class="button-group"><a class="button border-red" href="javascript:void(0)" onclick="system_category_del(this,{$vo.id})"><span class="icon-shanchu"></span> 删除</a> </div></td>
        </tr>
        {/volist}
    </table>
  </div>
  {$annxpic->render()}
</form>

<script type="text/javascript">

// 全选
jQuery(function($){
  //全选 
  $("#checkall").click(function(){ 
      $("input[name='id[]']").attr("checked","true"); 
  })
})
function delall(){
  layer.confirm('是否全部删除',function(){
    var ids= new Array(); 
    var thumbs= new Array(); 
    $("input[name='id[]']:checkbox:checked").each(function(){ 
      ids.push($(this).val());
      thumbs.push($(this).attr("title"));//attr获取多个属性
    });
    var idj=ids.join(",");
    var thumb=thumbs.join(",");
    $.ajax({
      type:"GET",
      url:"{:url('annx/delall')}",
      data:{
        'id':idj,
        'thumb':thumb,
      },
      success:function(data){
        var data=eval("("+data+")");
        if (data.status) {
          parent.layer.msg('删除成功~！',{icon:1,time:1000,},function(){parent.location.reload();});
        }else{
          parent.layer.msg('删除失败~！',{icon:2,time:1000,},function(){parent.location.reload();});
        }
      }
    })
  });
}

// 单个删除
function system_category_del(obj, id) {

  layer.confirm('确认要删除吗？', function (index) {

    $.ajax({
        type: "POST",
        url: "{:url('annx/del')}",
        data: {
        'id':id,
        },
        dataType: "json",
        success: function(data){
          var data=eval("("+data+")");

        if (data.status == 1){

          parent.layer.msg('删除成功~！',{icon:1,time:1000,},function(){parent.location.reload();});
        
        }
        else{
        parent.layer.msg('删除失败~！',{icon:2,time:1000,},function(){parent.location.reload();});
        }
        }
      });
    });
}
</script>
</body>
</html>